import axios, { Axios } from 'axios';
import { ref } from 'vue'
import { stringifys} from "../Utils/Tool"


//const http = ref("http://101.43.85.208:8080/api")  //上线
const http = ref("http://localhost:5198/api")

//获取天气
export const weather = (parms:{}) => {
    return axios.post("https://v2.alapi.cn/api/tianqi",parms); 
}
//获取博客文章
export const getblog = (BlogReq:{}) => {
    return axios.post(http.value+"/Blog/GetBlog",BlogReq);
}
//获取文章、分类、标签数量
export const BlogCount = () => {
    return axios.get(http.value+"/Blog/GetBlogCount");
}
//获取用户头像、昵称
export const UserAvatar = (UserReq:{}) => {
    return axios.post(http.value+"/Blog/UserAvatar",UserReq);
}
//获取分类列表
export const GetType= () =>{
    return axios.get(http.value+"/Type/GetTypes");
}
//获取分类和文章数量列表
export const GetTypeCount = () =>{
    return axios.get(http.value+"/Type/GetTypeCount");
}
//按年月归档
export const YearMonthArchive = () =>{
    return axios.get(http.value+"/Blog/YearMonthArchive");
}
//获取标签列表
export const GetTag = () =>{
    return axios.get(http.value+"/Tag/GetTags");
}


//后台管理
//添加文章
export const addblog = (blog:{},tagids:number[]) =>{
    return axios.post(http.value+"/Blog/AddBlog?"+stringifys(tagids,"tagids"),blog);
}
//博客文章带分页
export const admingetblog = (BlogReq:{}) =>{
    return axios.post(http.value+"/Blog/AdminGetBlog",BlogReq);
}
//删除文章
export const DelBlog = (blog:{}) =>{
    return axios.post(http.value + "/Blog/DelBlog",blog);
}


